<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sj" tagdir="/WEB-INF/tags/spring-jquery-tags"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<link href="<c:url value='/css/tablesorter.css' />" rel="stylesheet" type="text/css"/>
<link href="<c:url value='/css/jquery.tablesorter.pager.css' />" rel="stylesheet" type="text/css"/>
<link href="<c:url value='/css/dhtmlxcombo.css' />" rel="stylesheet" type="text/css"/>
<script type="text/javascript">
	$(document).ready(function() {
	//$(".tablesorter").tablesorter().tablesorterPager({container: $("#pager")});	       
		$('#editCipeprojectForm input, #editCipeprojectForm select').keypress(function(e) {
      		if(e.which == 13) {      
            	jQuery('#loginFormSubmit').click();
            	return false;
       		}
   		});	
	
		$('#pageTitle').text('<spring:message code="findCipeproject.heading" />');
		
		$("#editCipeprojectForm").validate({
			rules : {
				name : {
					required : false
				}
			}
		});
		$("#reset").click(function(){
			$("#content").load("../secure/findCipeproject.do");
		});
		
		$('#loginFormSubmit').click(function() {
		 //alert("hi" +$('#finalManagementFunds').val() );
		 
		  var v1= $('#projectID').val();
		  var v2= $('#acronym').val();
		 // var v3=$('#partner\\.id').val();
		   var v3= $('.dhx_combo_input:eq(0)').val();		 
		  var v4=$('#projectTitle').val();
		 // var v5=$('#cipeprojecttype\\.id').val();
		  var v5= $('.dhx_combo_input:eq(1)').val();
		     
		 // var v6=$('#programOfficer\\.id').val();
		  var v6= $('.dhx_combo_input:eq(2)').val();
		
		  //var v7=$('#programAssistant\\.id').val();
		  var v7= $('.dhx_combo_input:eq(3)').val();		 
		//  var v8=$('#region\\.id').val();
		  var v8= $('.dhx_combo_input:eq(4)').val();
		
		 // var v9=$('#country\\.id').val();
		  var v9= $('.dhx_combo_input:eq(5)').val();
		  //alert(v9);
		 // var v10=$('#cipeprojectstatus\\.id').val();
		  var v10= $('.dhx_combo_input').eq(6).val();
		 // alert(v10);
		  var v11=$('#fiscalYear').val();
		  var v12 = $('#initialProjectStartDate').val();
		  var v13 = $('#finalProjectStartDate').val();
		  var v14 = $('#initialProjectEndDate').val();
		  var v15 = $('#finalProjectEndDate').val();
		  var v16 = $('#initialManagementFunds').val();
		  var v17 = $('#finalManagementFunds').val();
		 
		 if(v1!='' || v2!='' || v3!=''|| v4!='' || v5!='' || v6!='' || v7!='' || v8!='' || v9!='' || v10!='' || v11!='' || v12!='' || v13!='' || v14!='' || v15!=''|| v16!=''|| v17!=''){		    
		   return true;
		 }
		 alert("Please enter at least one filter criteria");
		 return false;
		});
		
		$('.edit-cipeproject-link').click(function() {
			loadDiv('content', 'showEditCipeproject.do?id=' + $(this).attr('cipeprojectId'));
		});
		$(function() {
			$("#initialProjectStartDate").datepicker();
		});
		$(function() {
			$("#finalProjectStartDate").datepicker();
		});
		$(function() {
			$("#initialProjectEndDate").datepicker();
		});
					
		var z = dhtmlXComboFromSelect("partner_id",274);
		z.enableFilteringMode(true);
		var z1 = dhtmlXComboFromSelect("country_id",274);
		z1.enableFilteringMode(true);
		
		var z2 = dhtmlXComboFromSelect("region_id",274);
		z2.enableFilteringMode(true);
		
		var z3 = dhtmlXComboFromSelect("programAssistant_id",274);
		z3.enableFilteringMode(true);

		var z4 = dhtmlXComboFromSelect("programOfficer_id",274);
		z4.enableFilteringMode(true);
		
		var z5 = dhtmlXComboFromSelect("cipeprojecttype_id",274);
		z5.enableFilteringMode(true);
		
		var z5 = dhtmlXComboFromSelect("cipeprojectstatus_id",274);
		z5.enableFilteringMode(true);
		
		$(function() {
			$("#finalProjectEndDate").datepicker();
		});
	});

	$('.view-knowledgemanagementsearch-link').click(function() {
		loadDiv('content', 'findKnowledgeManagement.do');
	});

	
	$('.close-button').click(function() {
		loadDiv('content', 'refreshDashboard.do');
     });
   
   /*
	$('#check-all').click(function() {           
          var checkBox = $('#paymentRqst input:checkbox');
          for(var i = 0; i < checkBox.length; i++) {
       	   checkBox[i].checked = this.checked;
          }
   	});*/
</script>
<div id="findCipeprojectDiv">
	<form:form name="editCipeprojectForm" id="editCipeprojectForm" action="findCipeproject.do" method="GET" modelAttribute="cipeproject">
		<form:hidden path="id" />
		<div class="main_form">
			<div class="form_head">
	    		<a href="#" class="close-button gray_btn floatR">Close Form</a>
	    		<a href="#" class="view-knowledgemanagementsearch-link blue_btn floatR"><spring:message code="findPartnergrant.link.viewKnowledgeManagement" /></a>
	    		<br class="clear" />
	    	</div>
	    	<div class="form_cont">
				<table cellspacing="5" width="100%">

					<tr class="row">
						<td class="input-field" colspan="5">
							<%@ include file="/common/messages.jsp" %>
						</td>
					</tr>
					<tr class="row">
						<td class="label"><spring:message code="editCipeproject.label.projectID" /></td>
						<td class="input-field">
							<form:input path="projectID" cssClass="input-full-width text_white" />
							<form:errors path="projectID" cssClass="error" />
						</td>
						<td width="50">&nbsp;</td>
						<td class="label"><spring:message code="editCipeproject.label.projectTitle" /></td>
						<td class="input-field">
							<form:input path="projectTitle" cssClass="input-full-width text_white" />
							<form:errors path="projectTitle" cssClass="error" />
						</td>
					</tr>
					<tr class="row">
						<td class="label"><spring:message code="editCipeproject.label.acronym" /></td>
						<td class="input-field">
							<form:input path="acronym" cssClass="input-full-width text_white" />
							<form:errors path="acronym" cssClass="error" />

						</td>
						<td width="50">&nbsp;</td>
							<td class="label"><spring:message code="editCipeproject.label.type" /></td>
						<td class="input-field">
							<form:select path="cipeprojecttype.id" cssClass="text_white" id="cipeprojecttype_id">
								<form:option value="" label="" />
								<form:options items="${cipeprojecttypeList}" itemValue="id" itemLabel="displayName" />
							</form:select>
							<form:errors path="cipeprojecttype.id" cssClass="error"/>
						</td>					

					</tr>
					<tr class="row">
						<td class="label"><spring:message code="editCipeproject.label.status" /></td>
						<td class="input-field">
							<form:select path="cipeprojectstatus.id" cssClass="text_white" id="cipeprojectstatus_id">
								<form:option value="" label="" />
								<form:options items="${cipeprojectstatusList}" itemValue="id" itemLabel="displayName" />
							</form:select></td>
							<form:errors path="cipeprojecttype.id" cssClass="error" />
						</td>					
					<td width="50">&nbsp;</td>
					<!--<tr class="row">
						<td class="label"><spring:message code="editCipeproject.label.seniorProgramOfficer" /></td>
						<td class="input-field"><form:select path="seniorProgramOfficer.id">
								<form:options items="${seniorProgramOfficerList}" itemValue="id" itemLabel="fullName" />
							</form:select></td>
						<td><form:errors path="seniorProgramOfficer.id" cssClass="error" /></td>
					</tr>
					-->
						<td class="label"><spring:message code="editCipeproject.label.programOfficer" /></td>
						<td class="input-field">
							<form:select path="programOfficer.id" cssClass="text_white" id="programOfficer_id">
								<form:option value="" label="" />
								<form:options items="${programOfficerList}" itemValue="id" itemLabel="fullName" />
							</form:select>
							<form:errors path="programOfficer.id" cssClass="error" />
						</td>
					</tr>
					<tr class="row">
						<td class="label"><spring:message code="editCipeproject.label.region" /></td>
						<td class="input-field">
								<form:select path="region.id" cssClass="text_white" id="region_id">
								<form:option value="" label="" />
								<form:options items="${regionList}" itemValue="id" itemLabel="displayName" />
							</form:select>
							<form:errors path="region.id" cssClass="error" />

						</td>
						<td width="50">&nbsp;</td>
						<td class="label"><spring:message code="editCipeproject.label.programAssistant" /></td>
						<td class="input-field">
							<form:select path="programAssistant.id" cssClass="text_white" id="programAssistant_id">
								<form:option value="" label="" />
								<form:options items="${programAssistantList}" itemValue="id" itemLabel="fullName" />
							</form:select>
							<form:errors path="programAssistant.id" cssClass="error" />
						</td>
					</tr>
					<tr class="row">
						<td class="label"><spring:message code="editCipeproject.label.country" /></td>
						<td class="input-field">
							<form:select path="country.id" cssClass="text_white" id="country_id">
								<form:option value="" label=""/>
								<form:options items="${countryList}" itemValue="id" itemLabel="displayName" />
							</form:select>
							<form:errors path="country.id" cssClass="error" />
						</td>
						<td width="50">&nbsp;</td>
						<td class="label"><spring:message code="editCipeproject.label.partner" /></td>
						<td class="input-field">
							<form:select path="partner.id" cssClass="text_white" id="partner_id">
								<form:option value="" label=""/>
								<form:options items="${partnerList}" itemValue="id" itemLabel="shortPartnerName" />
							</form:select></td>
							<form:errors path="partner.id" cssClass="error" />	

						</td>
					</tr>
					<tr class="row">
						<td class="label"><spring:message code="editCipeproject.label.fiscalYear" /></td>
						<td class="input-field">
							<form:input path="fiscalYear" cssClass="input-full-width text_white" /></td>
							<form:errors path="fiscalYear" cssClass="error" />
						</td>
						<td width="50">&nbsp;</td>
						<td class="label">&nbsp;</td>
	                	<td></td>
	                </tr>
	                <tr>
						<td class="label"><spring:message code="editCipeproject.label.startDateBetween" /></td>
						<td class="input-field">
							<form:input path="initialProjectStartDate" cssClass="text_white"/>
							<form:errors path="initialProjectStartDate" cssClass="error" />
						</td>
						<td width="50">&nbsp;</td>
						<td class="label"><spring:message code="label.and" /></td>
						<td class="input-field">
							<form:input path="finalProjectStartDate" cssClass="text_white"/>
							<form:errors path="finalProjectStartDate" cssClass="error" />
						</td>
					</tr>
					<tr>
						<td class="label"><spring:message code="editCipeproject.label.endDateBetween" /></td>
						<td class="input-field">
							<form:input path="initialProjectEndDate" cssClass="input-full-width text_white" />
							<form:errors path="initialProjectEndDate" cssClass="error" />
						</td>
						<td width="50">&nbsp;</td>
						<td class="label"><spring:message code="label.and" /></td>
						<td class="input-field">
							<form:input path="finalProjectEndDate" cssClass="input-full-width text_white" />
							<form:errors path="finalProjectEndDate" cssClass="error" />
						</td>
					</tr>
					<tr class="row">
						<td class="label"><spring:message code="editCipeproject.label.managementFundsBetween" /></td>
						<td class="input-field">
							<form:input path="initialManagementFunds" cssClass="input-full-width text_white" />
							<form:errors path="initialManagementFunds" cssClass="error" />
						</td>
						<td width="50">&nbsp;</td>
						<td class="label"><spring:message code="label.and" /></td>
						<td class="input-field">
							<form:input path="finalManagementFunds" cssClass="input-full-width text_white" />
							<form:errors path="finalManagementFunds" cssClass="error" />
						</td>
					</tr>
					<tr>
	                	<td class="label">&nbsp;</td>
	                	<td>&nbsp;</td>
	                	<td width="50">&nbsp;</td>
	                	<td class="label">&nbsp;</td>
	                	<td></td>
	              	</tr>
					<tr class="row">
						<td class="input-field" align="center" colspan="5">
							<sj:submit id="loginFormSubmit" name="initiateSearch" cssClass="blue_btn" target="content" key="findCipeproject.button.search" validate="true" tabindex="-1"/>
							<input type="button" id="reset" class="blue_btn" value="<spring:message code='findCipeproject.button.reset' />" tabindex="-1"/>
						</td>
					</tr>
				</table>
				<div id="cipeprojectListDiv" class="hastable" style="overflow: auto">	
	                <c:if test="${!empty initiateSearch }">							
	                    <%@ include file="/WEB-INF/jsps/searchResultFindCiproject.jsp" %>				               
	               </c:if> 
                </div>
			</div>
		</div>				
	</form:form>
</div>